package com.sinaapp.mspring.controller;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sinaapp.mspring.annotation.SystemControllerLog;
import com.sinaapp.mspring.model.pojo.Iqiyi;
import com.sinaapp.mspring.service.IqiyiServiceI;
import com.sinaapp.mspring.model.vo.PageParameter;

/**
 * 分页专题
 * @author binchao
 * 2016年3月1日
 */
@Controller
@RequestMapping("/pagination")
public class PaginationController {
	
	private static Logger log = Logger.getLogger(PaginationController.class);
	
	//视图根目录
	private static final String rootPath = "/pagination/";
	
	@Autowired
	private IqiyiServiceI iqiyiService;
	
	
	@RequestMapping(value = "")
	@SystemControllerLog(description = "分页专题首页")
	public ModelAndView index(PageParameter pageParameter) {
		ModelAndView view = new ModelAndView(rootPath + "index");
		List<Iqiyi> iqiyis = iqiyiService.selectList(pageParameter);
		view.addObject("page", pageParameter);
		view.addObject("list", iqiyis);
		//log.info(iqiyis.size());
		return view;
	}
	
	@RequestMapping("/view")
	@SystemControllerLog(description = "电影详情")
	public ModelAndView view(Integer id) {
		ModelAndView view = new ModelAndView(rootPath + "detail");
		Iqiyi iqiyi = iqiyiService.selectByKey(id); //获取电影详情
		
		view.addObject("detail", iqiyi);
		
		return view;
	}
}
